<template>
  <el-dialog
    title="托药详情"
    :visible.sync="visibleDialog"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    width="30%"
  >
    <div>
      <div class="title">症状</div>
      <div class="content">
        {{ info.situation }}
      </div>

      <div class="title">托药列表</div>
      <div class="content">
        <div v-for="(item, index) in info.medicines" :key="index" class="medicines">
          <div class="info">
            {{ item.name }} | {{ item.way }} | {{ item.dailyTimes }}次 | 每次{{ item.quotaPerTime }}{{ item.unit }}
          </div>
          <div class="info">
            {{ item.daytimeList }}
          </div>
          <div class="info">
            {{ item.remark }}
          </div>
          <div v-if="item.image" class="info">
            <div v-for="(image, iIndex) in item.image.split('|')" :key="iIndex">
              <a-image :url="image" width="120px" height="120px" :preview="true" />
            </div>
          </div>
        </div>
      </div>

      <div v-if="info.adviceImg">
        <div class="title">医嘱照片</div>
        <div class="content">
          <div v-for="(image, iIndex) in info.adviceImg.split('|')" :key="iIndex">
            <a-image :url="image" width="120px" height="120px" :preview="true" />
          </div>
        </div>
      </div>

      <div v-if="info.attorneyImg">
        <div v-if="info.adviceImg" class="title">委托照片</div>
        <div class="content">
          <div v-for="(image, iIndex) in info.attorneyImg.split('|')" :key="iIndex">
            <a-image :url="image" width="120px" height="120px" :preview="true" />
          </div>
        </div>
      </div>

      <div v-if="info.assignImg">
        <div class="title">委托签名</div>
        <div class="content">
          <div v-for="(image, iIndex) in info.assignImg.split('|')" :key="iIndex">
            <a-image :url="image" width="120px" height="120px" :preview="true" />
          </div>
        </div>
      </div>

    </div>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="visibleDialog = false">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import AImage from '@/components/Basic/Image'
export default {
  name: 'DrugDialog',
  components: { AImage },
  props: {
    visible: [Boolean],
    info: {
      type: Object,
      default: () => ({})
    }
  },
  computed: {
    // 通过计算属性，对.sync进行转换，外部也可以直接使用visible.sync
    visibleDialog: {
      get () {
        return this.visible
      },
      set (val) {
        this.$emit('update:visible', val)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
  .title{
    font-size: 22px;
    font-family: PingFang SC;
    font-weight: bold;
    color: #333333;
    line-height: 24px;
  }

  .content{
    margin-top: 10px;
    margin-bottom: 30px;

    font-size: 15px;
    font-family: PingFang SC;
    font-weight: 400;
    color: #6E645A;
    line-height: 24px;
  }

  .medicines{

    .info{
      margin-top: 5px;
    }
  }
</style>
